<?php
namespace Tbf\ClassKit;
use Tbf\Error;
/**
 * 将当前类A附加到另一个类B里面去
 * A可以调用B的方法和变量
 * 但是B不能调用A的方法
 * @deprecated
 * */
class MaxIn {
    protected $origin = null;

    public function __construct($origin) { 
       $this->origin = $origin;
    } //End Of Func
    
     public  function __call( $name, $args ) {
         if (!is_callable(array($this->origin,$name))){
             throw new Error\BadMethodCallException(
                 'Undefined method "'.$name.'" in class "'.get_class($this).'"');
         }
         return call_user_func_array(array($this->origin,$name),$args);
     } 

    /** 
     * maxin到附加的controller里面去。
     **/
    function __isset($name){
        if (isset($this->origin->$name)){
            $this->{$name} = $this->origin->$name;
            return true;
        }   
        return false;
    }   

    function __get($name) {
        if( isset($this->$name) ) {
            return $this->$name;
        }//End Of If
        throw new \Exception('Access Undefined Value '.$name);
    }//End Of Func

} //End Of Class
